/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pubguru.data;

import java.io.FileNotFoundException;
import java.io.IOException;

/**
 *
 * @author dao
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws FileNotFoundException, IOException 
    {
        //Integrate();
        //CheckDuplicate(DBType.MAS, DBType.DBLP);
        //CheckDuplicate(DBType.MAS, DBType.CiteSeer);
        CheckDuplicate(DBType.DBLP, DBType.CiteSeer);
        
    }
    
    public enum DBType
    {
        CiteSeer,
        DBLP,
        MAS,     
    };
    
    public static void CheckDuplicate(DBType db1,DBType db2) throws FileNotFoundException, IOException
    {
        if (db1 == DBType.MAS)
        {
            String mas_paper = "C:/Data/mas_paper.txt";
            PaperData.getInstance().LoadData(mas_paper);
        }
        else if (db1 == DBType.DBLP)
        {
            String dblp_paper = "C:/Data/dblp_paper.txt";
            PaperData.getInstance().LoadData(dblp_paper);
        }
        
        if (db2== DBType.DBLP)
        {
            String dblp_paper = "C:/Data/dblp_paper.txt";
            String dblp_author = "C:/Data/dblp_author.txt";
            String dblp_author_paper = "C:/Data/dblp_author_paper.txt";
        
            DBLPIntegration dblpIntegration = new DBLPIntegration(dblp_paper, dblp_author, dblp_author_paper);
            dblpIntegration.Run();
            
            System.out.println("Number of overlapped paper (without paper missing infor) : " + PaperData.getInstance().GetNumberOfOverlappedPaper());
        }
        else if (db2 == DBType.CiteSeer)
        {
            System.out.println("Integrating CiteSeer");
            String citeseer_paper = "C:/Data/citeseer_paper.txt";
            String citeseer_author = "C:/Data/citeseer_author.txt";
            String citeseer_author_paper = "C:/Data/citeseer_author_paper.txt";

            CiteSeerIntegration citeSeerIntegration = new CiteSeerIntegration(citeseer_paper, citeseer_author, citeseer_author_paper);
            citeSeerIntegration.Run();
            
            System.out.println("Number of overlapped paper (without paper missing infor) : " + PaperData.getInstance().GetNumberOfOverlappedPaper());
        }
    }
    
    public static void Integrate() throws FileNotFoundException, IOException
    {
        // step 1 : Load Data MAS
        String mas_paper = "C:/Data/mas_paper.txt";
        //String mas_author = "C:/Data/mas_author.txt";
        
        PaperData.getInstance().LoadData(mas_paper);
        //AuthorData.getInstance().LoadData(mas_author);
        
        
        // step 2 : Integrate DBLP
        
        System.out.println("Integrating DBLP");
        String dblp_paper = "C:/Data/dblp_paper.txt";
        String dblp_author = "C:/Data/dblp_author.txt";
        String dblp_author_paper = "C:/Data/dblp_author_paper.txt";
        
        DBLPIntegration dblpIntegration = new DBLPIntegration(dblp_paper, dblp_author, dblp_author_paper);
        dblpIntegration.Run();
        
        // step 3 : Integrate CiteSeer
        
        System.out.println("Integrating CiteSeer");
        String citeseer_paper = "C:/Data/citeseer_paper.txt";
        String citeseer_author = "C:/Data/citeseer_author.txt";
        String citeseer_author_paper = "C:/Data/citeseer_author_paper.txt";
        
        CiteSeerIntegration citeSeerIntegration = new CiteSeerIntegration(citeseer_paper, citeseer_author, citeseer_author_paper);
        citeSeerIntegration.Run();
        
        
        // statistics data
        System.out.println("Number of overlapped paper (without paper missing infor) : " + PaperData.getInstance().GetNumberOfOverlappedPaper());
        System.out.println("Number of paper after integrating (without paper missing infor) : " + PaperData.getInstance().GetNumberOfPaper());
        int totalPaper = PaperData.getInstance().GetNumberOfPaper()
                        + PaperData.getInstance().totalPaperMissingInfor
                        + dblpIntegration.totalPaperMissingInfor
                        + citeSeerIntegration.totalPaperMissingInfor;
        System.out.println("Number of paper after integrating (including paper missing infor) : " + totalPaper);
    }
}
